﻿using System;
using System.Collections.Concurrent;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using InfiniteGeek.Util;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AutoConfigTests {
	[TestClass]
	public class AutoConfigParserFixture {
		readonly List<AutoConfigProperty> properties = AutoConfigParser<Config>.AutoConfigProperties;
		[TestMethod]
		public void Test_MultiValue_ShouldConvert() {
			Console.WriteLine(Config.ValueInConfig_String);
			Console.WriteLine(Config.ValueInConfig_Int32);

			const String delimiter = "|";

			Console.WriteLine(String.Join(delimiter, Config.ValueInConfig_StringArray));
			Console.WriteLine(String.Join(delimiter, Config.ValueInConfig_Int32Array));

			Console.WriteLine(String.Join(delimiter, Config.ValueInConfig_StringIEnum));
			Console.WriteLine(String.Join(delimiter, Config.ValueInConfig_Int32IEnum));
										  
			Console.WriteLine(String.Join(delimiter, Config.ValueInConfig_StringList));
			Console.WriteLine(String.Join(delimiter, Config.ValueInConfig_Int32List));
		}

		[TestMethod]
		public void Test_AutoConfigProperties_ShouldPopulate() {
			Assert.IsTrue(properties.Any());
		}
		
		[TestMethod]
		public void Test_AutoConfigProperties_ShouldIgnore() {
			Assert.IsFalse(properties.Any(p => p.Name == "Ignored"));
		}
		
		[TestMethod]
		public void Test_AutoConfigProperties_ShouldDefault() {
			Assert.IsTrue(properties.First(p => p.Name == "Default").Value == "foo");
		}

		[TestMethod]
		public void Test_KeyPrefixSearchList_ShouldPopulate() {
			Assert.IsTrue(AutoConfigParser<Config>.KeyPrefixSearchList.ToList().Any());
		}
	}
}
